package com.hangzhou.welbeing.welbeinginstrument.utils;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;

/**
 * 杭州惟君医疗科技有限公司16
 * Created by 20433 on 2018/1/29
 */

public class AutoGridLayoutManager extends GridLayoutManager
{
    private int measuredHeight = 0;
    private int measuredWidth = 0;

    public AutoGridLayoutManager(Context paramContext, int paramInt)
    {
        super(paramContext, paramInt);
    }

    public AutoGridLayoutManager(Context paramContext, int paramInt1, int paramInt2, boolean paramBoolean)
    {
        super(paramContext, paramInt1, paramInt2, paramBoolean);
    }

    public AutoGridLayoutManager(Context paramContext, AttributeSet paramAttributeSet, int paramInt1, int paramInt2)
    {
        super(paramContext, paramAttributeSet, paramInt1, paramInt2);
    }

    public void onMeasure(RecyclerView.Recycler paramRecycler, RecyclerView.State paramState, int paramInt1, int paramInt2)
    {
        if (this.measuredHeight <= 1)
        {
           View paramRecycler_01 = paramRecycler.getViewForPosition(0);
            if (paramRecycler != null)
            {
                measureChild(paramRecycler_01, paramInt1, paramInt2);
                this.measuredWidth = View.MeasureSpec.getSize(paramInt1);
                this.measuredHeight = (paramRecycler_01.getMeasuredHeight() * getSpanCount());
            }
        }
        setMeasuredDimension(this.measuredWidth, this.measuredHeight);
    }
}